package com.wangdao.wechatmall.controller.admin;

import com.wangdao.wechatmall.bean.bo.admin.CommentParamBO;
import com.wangdao.wechatmall.bean.pojo.Comment;
import com.wangdao.wechatmall.bean.vo.admin.BaseDataVO;
import com.wangdao.wechatmall.bean.vo.admin.BaseRespVo;
import com.wangdao.wechatmall.service.admin.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: JK
 * @Date: create in 2021/7/10 15:35
 */
@RestController
@RequestMapping("admin/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    /**
     * 查询评论列表
     * @param param
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list(CommentParamBO param) {
        BaseDataVO<Comment> baseDataVO = commentService.queryCommentList(param);
        return BaseRespVo.ok(baseDataVO);
    }

    /**
     * 删除评论
     * @param comment
     * @return
     */
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Comment comment) {
        int result = commentService.deleteComment(comment);

        if (result == 1) {
            return BaseRespVo.ok();
        }
        return BaseRespVo.fail();
    }
}
